using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace QuanLyKhachHang.DAO
{
	#region using
	using System.Data;
	using QuanLyKhachHang.DTO;
	#endregion
	public class KH_CO_SD_TIEMNANGDAO : AbstractDAO
	{
		public KH_CO_SD_TIEMNANGDAO(String strPath): base(strPath)
		{
		}

		~KH_CO_SD_TIEMNANGDAO()
		{
			base.Dispose();
		}

		public DataSet SelectAll()
		{
			DataSet ds;
			try
			{
				ds = new DataSet();
				base.sql = "usp_KH_CO_SD_TIEMNANG_SelectAll";
				base.FillDataSet(ref ds, "KH_CO_SD_TIEMNANG");
				return ds;
			}
			catch(System.Exception e)
			{
				throw new Exception(e.Message, e.InnerException);
			}
			finally
			{
				base.CleanUpObject();
			}
		}

		public DataSet SelectByID(string stt)
		{
			DataSet ds;
			try
			{
				ds = new DataSet();
				base.sql = "usp_KH_CO_SD_TIEMNANG_SelectByID";
				base.InitializeCommand();
				base.AddParameter("@STT", SqlDbType.NVarChar, 100, stt);
				base.FillDataSet(ref ds, "KH_CO_SD_TIEMNANG");
				return ds;
			}
			catch(System.Exception e)
			{
				throw new Exception(e.Message, e.InnerException);
			}
			finally
			{
				base.CleanUpObject();
			}
		}

		public bool Insert(KH_CO_SD_TIEMNANGDTO obj)
		{
			try
			{
				base.sql = "usp_KH_CO_SD_TIEMNANG_Insert";
				base.InitializeCommand();
				base.AddParameter("@STT", SqlDbType.NVarChar, 100, obj.STT);
				base.AddParameter("@MADONVI", SqlDbType.NVarChar, 100, obj.MADONVI);
				base.AddParameter("@THANG", SqlDbType.Int, 100, obj.THANG);
				base.AddParameter("@NAM", SqlDbType.Int, 100, obj.NAM);
				base.AddParameter("@TENKH", SqlDbType.NVarChar, 100, obj.TENKH);
				base.AddParameter("@LOAIHINH", SqlDbType.NVarChar, 100, obj.LOAIHINH);
				base.AddParameter("@NGANH", SqlDbType.NVarChar, 100, obj.NGANH);
				base.AddParameter("@DIACHI", SqlDbType.NVarChar, 100, obj.DIACHI);
				base.AddParameter("@DIENTHOAI", SqlDbType.NVarChar, 100, obj.DIENTHOAI);
				base.AddParameter("@FAX", SqlDbType.NVarChar, 100, obj.FAX);
				base.AddParameter("@NGAYKINIEM", SqlDbType.NVarChar, 100, obj.NGAYKINIEM);
				base.AddParameter("@TENNV", SqlDbType.NVarChar, 100, obj.TENNV);
				base.AddParameter("@NGAYSINHNV", SqlDbType.NVarChar, 100, obj.NGAYSINHNV);
				base.AddParameter("@DIENTHOAINV", SqlDbType.NVarChar, 100, obj.DIENTHOAINV);
				base.AddParameter("@EMAILNV", SqlDbType.NVarChar, 100, obj.EMAILNV);
				base.AddParameter("@DICHVU", SqlDbType.NVarChar, 100, obj.DICHVU);
				base.AddParameter("@SL", SqlDbType.Int, 100, obj.SL);
				base.AddParameter("@DOANHTHU", SqlDbType.BigInt, 100, obj.DOANHTHU);
				return ExecuteStoredProcedure();
			}
			catch
			{
				return false;
			}
		}

		public bool Delete(string stt)
		{
			try
			{
				base.sql = "usp_KH_CO_SD_TIEMNANG_Delete";
				base.InitializeCommand();
				base.AddParameter("@STT", SqlDbType.NVarChar, 100, stt);
				return ExecuteStoredProcedure();
			}
			catch
			{
				return false;
			}
		}

		public bool Update(KH_CO_SD_TIEMNANGDTO obj)
		{
			try
			{
				base.sql = "usp_KH_CO_SD_TIEMNANG_Update";
				base.InitializeCommand();
				base.AddParameter("@STT", SqlDbType.NVarChar, 100, obj.STT);
				base.AddParameter("@MADONVI", SqlDbType.NVarChar, 100, obj.MADONVI);
				base.AddParameter("@THANG", SqlDbType.Int, 100, obj.THANG);
				base.AddParameter("@NAM", SqlDbType.Int, 100, obj.NAM);
				base.AddParameter("@TENKH", SqlDbType.NVarChar, 100, obj.TENKH);
				base.AddParameter("@LOAIHINH", SqlDbType.NVarChar, 100, obj.LOAIHINH);
				base.AddParameter("@NGANH", SqlDbType.NVarChar, 100, obj.NGANH);
				base.AddParameter("@DIACHI", SqlDbType.NVarChar, 100, obj.DIACHI);
				base.AddParameter("@DIENTHOAI", SqlDbType.NVarChar, 100, obj.DIENTHOAI);
				base.AddParameter("@FAX", SqlDbType.NVarChar, 100, obj.FAX);
				base.AddParameter("@NGAYKINIEM", SqlDbType.NVarChar, 100, obj.NGAYKINIEM);
				base.AddParameter("@TENNV", SqlDbType.NVarChar, 100, obj.TENNV);
				base.AddParameter("@NGAYSINHNV", SqlDbType.NVarChar, 100, obj.NGAYSINHNV);
				base.AddParameter("@DIENTHOAINV", SqlDbType.NVarChar, 100, obj.DIENTHOAINV);
				base.AddParameter("@EMAILNV", SqlDbType.NVarChar, 100, obj.EMAILNV);
				base.AddParameter("@DICHVU", SqlDbType.NVarChar, 100, obj.DICHVU);
				base.AddParameter("@SL", SqlDbType.Int, 100, obj.SL);
				base.AddParameter("@DOANHTHU", SqlDbType.BigInt, 100, obj.DOANHTHU);
				return ExecuteStoredProcedure();
			}
			catch
			{
				return false;
			}
		}

		public DataSet SelectByMADONVI(string madonvi)
		{
			DataSet ds;
			try
			{
				ds = new DataSet();
				base.sql = "usp_KH_CO_SD_TIEMNANG_SelectByMADONVI";
				base.InitializeCommand();
				base.AddParameter("@MADONVI", SqlDbType.NVarChar, 100, madonvi);
				base.FillDataSet(ref ds, "KH_CO_SD_TIEMNANG");
				return ds;
			}
			catch(System.Exception e)
			{
				throw new Exception(e.Message, e.InnerException);
			}
			finally
			{
				base.CleanUpObject();
			}
		}

	}
}